<template>
  <!-- 计数器 -->
  <div class="pho-form-item" :style="newStyle">
    <van-field
      v-model="formValue"
      v-bind="$attrs"
      :name="$attrs.__vModel__"
      :required="$attrs.required"
      :rules="$attrs.regList"
      :placeholder="$attrs.placeholder"
      input-align="right"
    >
      <span v-if="showLabel" slot="label" :style="newStyle.font">{{$attrs.label}}</span>
      <template #input>
        <span v-if="$attrs.onlyShow">{{value}}</span>
        <van-stepper
          v-else
          v-model="formValue"
          v-bind="$attrs"
          :decimal-length="$attrs.precision"
          @input="onInput"
          @blur="onBlur"
          @change="onChange"
          @focus="onFocus"
        />
      </template>
    </van-field>
  </div>
</template>

<script>
import { comMixin } from "../../../utils/comMixins";
export default {
  mixins: [comMixin],
  name: "phone-form-input-number",
  model: {
    prop: "value", // 绑定的值，通过父组件传递
    event: "update",
  },
  props: {
    value: {
      type: [Number, String],
      default: 0,
    },
    // 是否展示标题
    showLabel: {
      type: Boolean,
      default: true,
    },
  },
  computed: {
    formValue: {
      get() {
        return this.value;
      },
      set(val) {
        this.$emit("update", val);
        this.$emit("change", val);
      },
    },
  },
};
</script>

<style lang="scss" scoped></style>
